import textHtml from 'ngtemplate!html!../../../tpls/validation/text.html';
import phoneHtml from 'ngtemplate!html!../../../tpls/validation/phone.html';

class CompanyViewController {
    constructor($rootScope, $scope, $cookieStore, $timeout, $state, ngDialog, dialogService, CompanyService, getCompanyDetail, fileReader, iRunner){

    	var vm = this;

    	vm.$rootScope       = $rootScope;
        vm.$scope           = $scope;
    	vm.$cookieStore     = $cookieStore;
    	vm.$timeout 	    = $timeout;
    	vm.$state   	    = $state;
    	vm.ngDialog 	    = ngDialog;
    	vm.dialogService    = dialogService;
    	vm.CompanyService   = CompanyService;
        vm.getCompanyDetail = getCompanyDetail;
    	vm.fileReader       = fileReader;
    	vm.iRunner 	   	    = iRunner; 

    	vm.textHtml  = textHtml;
    	vm.phoneHtml = phoneHtml;

    	// 机构类型
        vm.company_types = iRunner.raceScaleConfig;

        // 表单数据初始化
        vm.company = {};

        // 获取当前赛事机构基本信息
        if (vm.getCompanyDetail.code==0) {

            var Detail = vm.getCompanyDetail.data;

            // 机构名称
            vm.company.company_name = Detail.company_name;
            //所在城市：
            vm.company.city = Detail.city;
            //每年赛事场次：
            vm.company.race_frequency = Detail.race_frequency;
            //主要赛事规模：
            vm.company.race_scale = Detail.race_scale;
            //联系方式：手机
            vm.company.user_cell = Detail.user_cell;
            //电子邮箱
            vm.company.user_mail = Detail.user_mail;
            //短信剩余
            vm.company.points = Detail.points / 10;
            //赛事机构LOGO
            vm.company.logo = Detail.logo;
            //机构角色：
            angular.forEach(vm.company_types, function(data,index,array){
                if (data.id == Detail.type) {
                    vm.company.company_name = data.name;
                    return;
                }
            });
        }
    }

}

CompanyViewController.$inject = ['$rootScope', '$scope', '$cookieStore', '$timeout', '$state', 'ngDialog', 'dialogService', 'CompanyService', 'getCompanyDetail', 'fileReader', 'iRunner']; 

export default CompanyViewController;